package com.tl.commonlibrary;

import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;

import com.tl.commonlibrary.network.NetConfig;
import com.tl.commonlibrary.network.NetManager;
import com.tl.commonlibrary.tool.DeviceUtil;

/**
 * Created by Administrator on 2017/6/9 0009.
 */

public class AppConfig {
    public static Application application;
    public static Context appContext;
    public static String appVersion = "unInit";
    public static int appVersionCode = 0;
    public static String appModel = "unInit";
    private static boolean DEBUGGABLE = false;

    public static final void setApplication(Application application) {
        AppConfig.application = application;
        if (application != null) {
            appContext = application.getApplicationContext();
            appVersion = DeviceUtil.getVersionName(appContext);
            appVersionCode = DeviceUtil.getVersionCode(appContext);
            appModel = DeviceUtil.getModel();
            ApplicationInfo info = application.getApplicationInfo();
            DEBUGGABLE = (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
//            DEBUGGABLE = true;
            NetConfig.init(DEBUGGABLE);
        }
    }

    public static final String getString(int resId) {
        if (appContext != null) {
            return appContext.getString(resId);
        }
        return "";
    }

    public static boolean DEBUG() {
        return DEBUGGABLE;
    }
}
